package com.own.business.wallet.entity.bo;

import com.own.business.wallet.entity.po.WalletHistory;
import com.own.component.common.base.entity.BaseBo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * WalletHistoryBo
 *
 * @author chenxueli
 * @date 2023-08-28 16:05:32
 */
@Schema(title = "钱包订单流水" + ConstantBeanSuffix.BO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class WalletHistoryBo extends BaseBo<WalletHistory> implements Serializable {

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "钱包id")
    private Long walletId;

    @Schema(title = "订单号")
    private String tradeNo;

    @Schema(title = "订单标题")
    private String subject;

    @Schema(title = "订单附加信息")
    private String body;

    @Schema(title = "商户订单号")
    private String outTradeNo;

    @Schema(title = "商户退款订单号")
    private String outRefundNo;

    @Schema(title = "订单总金额（分）")
    private Integer totalAmount;

    @Schema(title = "订单状态（1=新建 2=完成 4=订单关闭 5=超时取消）")
    private Integer status;

    @Schema(title = "订单过期时间")
    private LocalDateTime expireTime;

    @Schema(title = "回调地址")
    private String callback;

    @Schema(title = "支付时间")
    private LocalDateTime payTime;

    @Schema(title = "流水类型（1=收入 2=支出 3=退款）")
    private Integer type;

    /**
     * 转持久化对象
     *
     * @param entity 原持久化对象
     * @return 持久化对象
     */
    @Override
    public WalletHistory toPo(WalletHistory entity) {
        if (entity == null) {
            entity = new WalletHistory();
        }
        entity.setFkUserId(this.userId);
        entity.setFkWalletId(this.walletId);
        entity.setTradeNo(this.tradeNo);
        entity.setSubject(this.subject);
        entity.setBody(this.body);
        entity.setOutTradeNo(this.outTradeNo);
        entity.setOutRefundNo(this.outRefundNo);
        entity.setTotalAmount(this.totalAmount);
        entity.setStatus(this.status);
        entity.setExpireTime(this.expireTime);
        entity.setCallback(this.callback);
        entity.setPayTime(this.payTime);
        entity.setType(this.type);
        return super.toPo(entity);
    }

}

